# Maintainer: Ilya Rakhlin <i.rakhlin@gmail.com>

_realname=pkgconf
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.8
pkgrel=1
pkgdesc='pkg-config compatible utility which does not depend on glib'
url='https://github.com/pkgconf/pkgconf'
arch=('any')
license=('ISC')
options=('!debug' 'strip')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
source=(https://distfiles.dereferenced.org/pkgconf/$_realname-$pkgver.tar.gz
        0001-fix-mingw64-and-static.patch)
sha256sums=('fdac40205a50c77485f1f034a36bcda08d0935320b90bdba1734dc4436ba00ef'
            'f92d157c481128d301473b1cd229557ac25a75e0b6ffd6ff6bbf17be5b84c047')

prepare() {
  cd $_realname-$pkgver
  patch -p1 -i ${srcdir}/0001-fix-mingw64-and-static.patch
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}
  
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    ../${_realname}-${pkgver}
  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="$pkgdir" install
  cp "${pkgdir}${MINGW_PREFIX}"/bin/pkgconf "${pkgdir}${MINGW_PREFIX}"/bin/${MINGW_CHOST}-pkgconf
}
